From 0ac09351c4dc346d0c1d70d180c15732a4b2a3d7 Mon Sep 17 00:00:00 2001 From: Justin Burkett Date: Fri, 25 Nov 2016 09:00:25 -0500 Subject: [PATCH] Fix use of function in -replacement-alist Wasn't actually deleting nil results --- which-key.el | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/which-key.el b/which-key.el index b5b671c3833..6828f42fe2d 100644 --- a/which-key.el +++ b/which-key.el @@ -1299,6 +1299,7 @@ which are strings. KEY is of the form produced by `key-binding'." key-binding which-key-replacement-alist 'which-key--replacement-test)))) (cond ((null res) key-binding) + ((functionp res) (funcall res key-binding)) ((consp res) (cons (cond ((and (car res) (car which-key--last-replace-key)) @@ -1312,8 +1313,7 @@ which are strings. KEY is of the form produced by `key-binding'." (cdr which-key--last-replace-key) (cdr res) (cdr key-binding) t)) ((cdr res) (cdr res)) - (t (cdr key-binding))))) - ((functionp res) (funcall res key-binding))))) + (t (cdr key-binding)))))))) (defsubst which-key--current-key-list (&optional key-str) (append (listify-key-sequence which-key--current-prefix) @@ -1446,22 +1446,25 @@ alists. Returns a list (key separator description)." (let ((sep-w-face (propertize which-key-separator 'face 'which-key-separator-face)) (local-map (current-local-map))) - (mapcar - (lambda (key-binding) - (let* ((key (car key-binding)) - (orig-desc (cdr key-binding)) - (group (which-key--group-p orig-desc)) - (keys (which-key--current-key-string key)) - (local (eq (which-key--safe-lookup-key local-map (kbd keys)) - (intern orig-desc))) - (hl-face (which-key--highlight-face orig-desc)) - (key-binding (which-key--maybe-replace (cons keys orig-desc)))) - (list (which-key--propertize-key - (car (last (split-string (car key-binding) " ")))) - sep-w-face - (which-key--propertize-description - (cdr key-binding) group local hl-face orig-desc)))) - unformatted))) + (delq + nil + (mapcar + (lambda (key-binding) + (let* ((key (car key-binding)) + (orig-desc (cdr key-binding)) + (group (which-key--group-p orig-desc)) + (keys (which-key--current-key-string key)) + (local (eq (which-key--safe-lookup-key local-map (kbd keys)) + (intern orig-desc))) + (hl-face (which-key--highlight-face orig-desc)) + (key-binding (which-key--maybe-replace (cons keys orig-desc)))) + (when (consp key-binding) + (list (which-key--propertize-key + (car (last (split-string (car key-binding) " ")))) + sep-w-face + (which-key--propertize-description + (cdr key-binding) group local hl-face orig-desc))))) + unformatted)))) (defun which-key--get-keymap-bindings (keymap &optional filter) "Retrieve top-level bindings from KEYMAP." -- 2.30.2